﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Finance.Finances.Templates;
using mozhi.smarterp.Finance.Querys;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Finance.Finances
{
    [RemoteService]
    [Route("api/v1/journaltemplates")]
    public class JournalTemplateController : BaseController
    {
        private IJournalTemplateAppService _appService;
        public JournalTemplateController(IJournalTemplateAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        public async Task<PagedResultDto<JournalTemplateDto>> GetPageAsync(PageQuery query)
        {
            var result = await _appService.FindAsync(query);

            return result;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<JournalTemplateDto> GetAsync(Guid id)
        {
            var result = await _appService.GetAsync(id);

            return result;
        }

        [HttpPost]
        public async Task<JournalTemplateDto> CreateAsync(JournalTemplateCreateDto template)
        {
            var result = await _appService.CreateAsync(template);

            return result;
        }


        [HttpPut]
        public async Task<JournalTemplateDto> UpdateAsync(JournalTemplateUpdateDto template)
        {
            var result = await _appService.UpdateAsync(template);

            return result;
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
